<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/inc/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>申请店铺</title>
		<link type="text/css" rel="stylesheet" href="${path }/js/easyui/themes/default/easyui.css">
		<link type="text/css" rel="stylesheet" href="${path }/js/easyui/themes/icon.css">
		<script type="text/javascript" src="${path }/js/jquery-1.4.2.min.js"></script>
		<script type="text/javascript" src="${path }/js/easyui/jquery.easyui.min.js"></script>
		<script type="text/javascript">
			var path="${path}";
		</script>
		<script type="text/javascript" src="${path }/js/form/jquery.form.js"></script>
		<script type="text/javascript" src="${path}/js/date/My97DatePicker/WdatePicker.js"></script>
		<script type="text/javascript" src="${path }/js/zDialog.js"></script>
		<script type="text/javascript" src="${path }/js/zDrag.js"></script>
		<script type="text/javascript">
		
			$(document).ready(function() { 
					var options = {
						beforeSubmit: checkForm,
						dataType : 'json',
						success:addBack
					};
					
				 	$('#addForm').ajaxForm(options); 
				    
			}); 
			
			function checkForm(){
				//return false;
			}
			function addBack(json){
				if(json.result=="Success"){
					alert("申请已提交,请尽快付款,否则将会被人抢占!");
					refleshOpener();
				}else if(json.result == "Faile" &&json.ErrorCode == "-1"){
					alert("竞价不能比默认值小，默认值为:￥"+json.value+"/天");
				}else if(json.result == "Faile" &&json.ErrorCode == "-2"){
					alert("到期日期不能小于开店日期哦，并且租期最小要超过一天哦");
				}else if(json.result == "Faile" &&json.ErrorCode == "-3"){
					alert("不成功，似乎您出的单价比存在的申请的单价还小哦");
				}else if(json.result == "Faile" &&json.ErrorCode == "-4"){
					alert("不成功，在同等单价的情况下似乎你的天数要比存在的申请的租期要长呢");
				}else if(json.result == "Faile" &&json.ErrorCode == "-5"){
					alert("不成功，似乎有人比你要早，并且已经付款了哦");
				}else if(json.result == "Faile" &&json.ErrorCode == "-6"){
					alert("不成功，相同开店日期与到期日期的申请已经有了哦");
				}
			}
		
			function refleshOpener(){
				ownerDialog.opener.location = "/index";
				ownerDialog.close();
			}
			
			function changePrice(state){
				if(state == 1){
					$("#orderPrice").attr("disabled",true);
				}else if(state == 0){
					$("#orderPrice").attr("disabled",false);
				}
				
			}
		</script>
	</head>
	<body>
		<form action="${path}/order/save" method="post" id="addForm" name="addForm" >
			<div title="填写申请单" class="easyui-panel" style="width:500px;height:280px;padding:10px;background:#fafafa;">
				<table >
					<tr>
						<td>
							申请人:
						</td>
						<td>
							<input type="text"  id="orderMember" name="orderMember" size="40" value="${member.memberName }" readonly><font color="red">*</font>
						</td>
					</tr>
					<tr>
						<td>
							申请开店日期:
						</td>
						<td>
							<select name="orderRequestYear">
								<option value="-1">--请选择--</option>
								<c:forEach items="${years}" var="year">
									<option value="${year.key }">${year.value }</option>
								</c:forEach>
							</select>
							年
							<select name="orderRequestMonth">
								<option value="-1">--请选择--</option>
								<c:forEach items="${months}" var="month">
									<option value="${month.key }">${month.value }</option>
								</c:forEach>
							</select>
							月
							<select name="orderRequestDay">
								<option value="-1">--请选择--</option>
								<c:forEach items="${days}" var="day">
									<option value="${day.key }">${day.value }</option>
								</c:forEach>
							</select>
							日
						</td>
					</tr>
					<tr>
						<td>
							到期日期:
						</td>
						<td>
							<select name="orderEndYear">
								<option value="-1">--请选择--</option>
								<c:forEach items="${years}" var="year">
									<option value="${year.key }">${year.value }</option>
								</c:forEach>
							</select>
							年
							<select name="orderEndMonth">
								<option value="-1">--请选择--</option>
								<c:forEach items="${months}" var="month">
									<option value="${month.key }">${month.value }</option>
								</c:forEach>
							</select>
							月
							<select name="orderEndDay">
								<option value="-1">--请选择--</option>
								<c:forEach items="${days}" var="day">
									<option value="${day.key }">${day.value }</option>
								</c:forEach>
							</select>
							日
						</td>
					</tr>
					<tr>
						<td>
							单价:
						</td>
						<td>
							<input type="radio" name="isDefaultPrice" value="1" onclick="changePrice(1)"/>默认(￥100/天)
							<input type="radio" name="isDefaultPrice" value="0" onclick="changePrice(0)"/>竞价
							<input type="text"  id="orderPrice" name="orderPrice" size="20">
						</td>
					</tr>
					<tr>
						<td>
							申请说明:
						</td>
						<td>
							<textarea rows="5" cols="30" name="orderDesc"></textarea>
						</td>
					</tr>
					
				</table>
			</div>
			
			
			<div>
				<table>
					<tr>
						<td>
							<input type="submit" value="申请">
						</td>
					</tr>
				</table>
			</div>
			
		</form>
	</body>
</html>